package com.main.toyexchange;

/*
 * 个人中心的activity
 */

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bjtu.toyexchange.R;
import com.own.toyexchange.ModifyInfoActivity;
import com.own.toyexchange.OwnExch;
import com.own.toyexchange.OwnFabu;
import com.own.toyexchange.OwnNotRea;

public class GerenActivity extends Activity{
	private ImageView imageview, own_fabu, own_mes, own_exch;
	private TextView name, rightTV, fabu, mes, exch;
	private int num_fabu, num_mes, num_exch;
	private String username, right, password;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_geren);
        
        Intent intent = getIntent();
		Bundle bundle = intent.getExtras();
		//得到用户名、密码
		username = bundle.getString("username");
		password = bundle.getString("password");
        
        right = "普通用户。。。";
        
		
		//我的发布的按钮
		own_fabu = (ImageView)findViewById(R.id.own_fabu);
		own_fabu.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Intent int2 = new Intent();
				int2.putExtra("username", username);
				int2.setClass(GerenActivity.this, OwnFabu.class);
				GerenActivity.this.startActivity(int2);
			}
		});
		
		//未读申请的按钮
		own_mes = (ImageView)findViewById(R.id.own_mes);
		own_mes.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Intent int2 = new Intent();
				int2.putExtra("username", username);
				int2.setClass(GerenActivity.this, OwnNotRea.class);
				GerenActivity.this.startActivity(int2);
			}
		});
		
		//我的交换的按钮
		own_exch = (ImageView)findViewById(R.id.own_exch);
		own_exch.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Intent int2 = new Intent();
				int2.putExtra("username", username);
				int2.setClass(GerenActivity.this, OwnExch.class);
				GerenActivity.this.startActivity(int2);
			}
		});
		
		init();
	}

	private void init() {
		//设置为用户的用户名
		name = (TextView)findViewById(R.id.usernameV);
		name.setText(username);
		
		//设置为用户的个性签名
		rightTV = (TextView)findViewById(R.id.rightV);
		rightTV.setText(right);
		
		//设置为用户的头像
		imageview = (ImageView) findViewById(R.id.tx_pic);
		imageview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				//传递用户信息
				Intent intent = new Intent();
				intent.putExtra("username", username);
				intent.putExtra("password", password);
//				intent.putExtra("phone_num", phone_num);
//				intent.putExtra("provice", provice);
//				intent.putExtra("city", city);
//				intent.putExtra("distiact", distiact);
//				intent.putExtra("road", road);
//				intent.putExtra("number", number);
				intent.setClass(GerenActivity.this, ModifyInfoActivity.class);
				GerenActivity.this.startActivity(intent);
			}
		});
		Bitmap temp = BitmapFactory.decodeResource(this.getResources(),
				R.drawable.pic);
		Bitmap bitmap = ImageUtil.getRoundedCornerBitmap(temp);
		imageview.setBackgroundDrawable(new BitmapDrawable(bitmap));
		
		//设置为发布玩具的数目
		fabu = (TextView)findViewById(R.id.num_fabu);
		fabu.setText("0");
		
		//设置为未读信息的数目
		mes = (TextView)findViewById(R.id.num_mes);
		mes.setText("0");
		
		//设置为交换玩具的数目
		exch = (TextView)findViewById(R.id.num_exch);
		exch.setText("0");
	}

}
